package net.janeluo.rs.module;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.janeluo.rs.entity.RS_Orders;
import net.janeluo.rs.service.OrdersListService;

import org.apache.commons.lang.StringUtils;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 订单列表模块
 * 
 * @author DLK)JaneLuo
 * @version 1.0.0
 */
@IocBean
@At("/")
public class OrdersListModule {

    @Inject
    private OrdersListService ordersListService;
    
    /**
     * 初始化显示订单列表
     * @return 
     */
    @At("OrdersList")
    @Ok("jsp:views.OrdersList")
    public Map<String, List<RS_Orders>> initOrdersList(HttpServletRequest req, @Param("year")String year, @Param("month")String month,@Param("day")String day){
        month = StringUtils.leftPad(month, 2, "0");
        day = StringUtils.leftPad(day, 2, "0");
        String date = year + "/" + month + "/" + day;
        
        req.setAttribute("year", year);
        req.setAttribute("month", month);
        req.setAttribute("date", date);
        return ordersListService.getOrderList(date);
    }

}
